package tk.mynoteapp.dev.demo22.apiasyncsyncmode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("apiasyncsyncmode")
@RestController
public class APIAsyncSyncModeController {
    @Autowired
    private FileService fileService;

    @GetMapping("wrong")
    public UploadResponse upload() {
        UploadRequest request = new UploadRequest();
        return fileService.upload(request);
    }

    @GetMapping("syncUpload")
    public SyncUploadResponse syncUpload() {
        SyncUploadRequest request = new SyncUploadRequest();
        return fileService.syncUpload(request);
    }

    // 异步上传，搭配syncQueryUpload使用
    @GetMapping("asyncUpload")
    public AsyncUploadResponse asyncUpload() {
        AsyncUploadRequest request = new AsyncUploadRequest();
        return fileService.asyncUpload(request);
    }

    // 同步查询异步上传完成任务
    @GetMapping("syncQueryUpload")
    public SyncQueryUploadTaskResponse syncQueryUpload() {
        SyncQueryUploadTaskRequest request = new SyncQueryUploadTaskRequest();
        return fileService.syncQueryUploadTask(request);
    }
}
